#include <bits/stdc++.h>
const int NN = 5e5 + 4;
using namespace std;
int opv[NN * 4], pfx[NN * 4], sfx[NN * 4], len[NN * 4];
void maintain(int o, int lLen, int rLen) {
  int lc = 2 * o, rc = 2 * o + 1;
  pfx[o] = pfx[lc] == lLen ? lLen + pfx[rc] : pfx[lc];
  sfx[o] = sfx[rc] == rLen ? rLen + sfx[lc] : sfx[rc];
  len[o] = max(max(len[lc], len[rc]), pfx[rc] + sfx[lc]);
}
void push_down(int o, int lLen, int rLen) {
  int &op = opv[o];
  if (!op || !lLen || !rLen) return;
  int lc = 2 * o, rc = 2 * o + 1;
  len[lc] = pfx[lc] = sfx[lc] = (op == 2 ? lLen : 0);
  len[rc] = pfx[rc] = sfx[rc] = (op == 2 ? rLen : 0);
  opv[lc] = opv[rc] = op, op = 0;
}
int query(int o, int L, int R, int v) {
  // 在 o[L,R]中查找长度为q的连续0区间
  int lc = 2 * o, rc = 2 * o + 1, m = L + (R - L) / 2;
  push_down(o, m - L + 1, R - m);
  if (len[lc] >= v) return query(lc, L, m, v);         // 去左半边找
  if (pfx[rc] + sfx[lc] >= v) return m - sfx[lc] + 1;  // 横跨中间线
  return query(rc, m + 1, R, v);                       // 去右边找
}

void update(int qL, int qR, int op, int o, int L, int R) {
  int lc = 2 * o, rc = 2 * o + 1, m = L + (R - L) / 2;
  if (qL <= L && qR >= R) {
    len[o] = pfx[o] = sfx[o] = (op == 2 ? R - L + 1 : 0);
    opv[o] = op;
    return;
  }
  push_down(o, m - L + 1, R - m);
  if (qL <= m) update(qL, qR, op, lc, L, m);
  if (qR > m) update(qL, qR, op, rc, m + 1, R);
  maintain(o, m - L + 1, R - m);
}
void build(int o, int L, int R) {
  int lc = 2 * o, rc = 2 * o + 1, m = L + (R - L) / 2;
  len[o] = pfx[o] = sfx[o] = R - L + 1;
  if (L < R) build(lc, L, m), build(rc, m + 1, R);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m, ans = 0;
  char op;
  cin >> n >> m, build(1, 1, n);
  for (int i = 0, a, b; i < m; i++) {
    cin >> op >> a;
    if (op == 'A') {
      if (len[1] < a)
        ans++;
      else {
        int x = query(1, 1, n, a);
        update(x, x + a - 1, 1, 1, 1, n);
      }
    } else
      cin >> b, update(a, b, 2, 1, 1, n);
  }
  cout << ans << endl;
}
